<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.GregorianCalendar" %>
<%--
  Created by IntelliJ IDEA.
  User: gaoliwei02
  Date: 17/6/25
  Time: 上午10:31
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>task information</title>
</head>

<body>
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        task information
        <small>page</small>
    </h1>
</section>

<!-- Main content -->
<section class="content">
    <div class="box">
        <%--<div class="box-header with-border"></div><!-- /.box-header -->--%>
        <div class="box-body">

            <div class="row">
                <div class="col-lg-2  col-xs-6">
                    <label class="deviceId_search" for="deviceId_search">device_id</label>
                    <input type="text" class="form-control" id="deviceId_search" name="deviceId_search"
                           placeholder="">
                </div>

                <div class="col-lg-2  col-xs-6">
                    <label class="userId_search" for="userId_search">user_id</label>
                    <input type="text" class="form-control" id="userId_search" name="userId_search"
                           placeholder="">
                </div>
                <div class="col-lg-2  col-xs-6">
                    <label class="orderId_search" for="orderId_search">order_id</label>
                    <input type="text" class="form-control" id="orderId_search" name="orderId_search"
                           placeholder="">
                </div>
                <div class="col-lg-2  col-xs-6">
                    <label class="controlMsg_search" for="controlMsg_search">control_msg</label>
                    <input type="text" class="form-control" id="controlMsg_search" name="controlMsg_search"
                           placeholder="">
                </div>
                <div class="col-lg-4 col-xs-12">
                    <label for="deltaTime_search">deltaTime</label>

                    <div class="input-group" id="deltaTime_search">
                        <%
                            Date today = new Date();
                            GregorianCalendar gregorianCalendar = new GregorianCalendar();
                            gregorianCalendar.setTime(today);
                            gregorianCalendar.add(Calendar.DAY_OF_MONTH, -1);
                            Date yesterday = gregorianCalendar.getTime();
                            String yesterdayString = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(yesterday);
                            String todayString = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(today);
                        %>
                        <%--默认统计昨天的数据--%>
                        <input type="text" id="dateStart" class="form-control" name="start" value="<%=yesterdayString%>"/>
                        <span class="input-group-addon">to</span>
                        <input type="text" id="dateEnd" class="form-control" name="end" value="<%=todayString%>"/>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <div class="container removeLeftSpace">
        <div class="removeLeftSpace row">
            <div class="col-xs-2 col-lg-1 removeLeftSpace">
                <button class="btn btn-primary margin" style="width: 80px; margin-left: 0" onclick="search()">
                    <i class="fa fa-search" style=" margin-right: 4px;"></i>check
                </button>
            </div>
        </div>
    </div>

    <table id="task_check_table"
           data-toggle="table"
           data-side-pagination="server"
           data-sort-order="desc"
           data-pagination="true"
           data-page-size="15"
           data-page-list="[15, 50, 100, 500]"
           data-url="/task/getlist.inner"
           data-row-style="rowStyle"
           data-method="post"
           data-query-params="queryParams">
        <thead>
        <tr>
            <th data-field="userId">userId</th>
            <th data-field="deviceId">deviceId</th>
            <th data-field="orderId">orderId</th>
            <th data-field="createTime">createTime</th>
            <th data-field="durationSec">durationSec</th>
            <th data-field="sendStatus">sendStatus</th>
            <th data-field="controlMsg">controlMsg</th>
            <th data-field="userLocation">userLocation</th>
            <th data-field="executeResult">executeResult</th>
        </tr>
        </thead>
    </table>
    <!-- /.content -->
</section>
<script>
    function search() {
        var $table = $('#task_check_table');
        $table.bootstrapTable('refresh', {
            query: queryParams({
                pageNumber: 1
            })
        });
    }

    function queryParams(param) {

        var data = {
            pageSize: $(".page-size").text(),
            deviceId: $("#deviceId_search").val(),
            userId: $("#userId_search").val(),
            orderId: $("#orderId_search").val(),
            controlMsg: $("#controlMsg_search").val(),
            startTime: $('#dateStart').val(),
            endTime: $('#dateEnd').val(),
        };
        if (!data.pageSize) {
            data.pageSize = 50;
        }
        $.extend(param, data);
        return param;
    }

</script>


</body>
</html>
